package com.huifaapp.mall.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.huifaapp.mall.R;
import com.huifaapp.mall.adapter.ReturnafterAdapter;
import com.huifaapp.mall.fragment.AftersaleApplicationFragment;
import com.huifaapp.mall.fragment.ApplicationsRecordFragment;

import java.util.ArrayList;
import java.util.List;

public class ReturnaftersaleActivity extends AppCompatActivity {

    private TabLayout tab_layout;
    private ViewPager viewpager;
    private List<Fragment> fragments = new ArrayList<>();
    private List<String> list=new ArrayList<>();
    private ImageView Imback;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_returnaftersale);
        initView();
        list.add("售后申请");
        list.add("申请记录");
        ReturnafterAdapter returnafterAdapter = new ReturnafterAdapter(getSupportFragmentManager(),fragments,list);
        viewpager.setAdapter(returnafterAdapter);
        tab_layout.setupWithViewPager(viewpager);
        tab_layout.setTabsFromPagerAdapter(returnafterAdapter);
    }

    private void initView() {
        tab_layout = (TabLayout) findViewById(R.id.after_tab_layout);
        viewpager = (ViewPager) findViewById(R.id.after_viewpager);
        Imback = (ImageView) findViewById(R.id.iv_returnaftersale_back);
        Imback.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        fragments.add(new AftersaleApplicationFragment());
        fragments.add(new ApplicationsRecordFragment());
    }
}
